/**
*      author: Y_Yao
*      created: 2024-12-05 17:30:56
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 1e18;
const int INF = 0x3f3f3f3f;
const int N = 40 + 7;
const int M = 1e5 + 7;
string s;
int n;
int num[N][N];
int dp[N][M];

void solve()
{
    cin >> s;
    cin >> n;
    int len = s.size();

    // for(int i = 0;i < s.size();i++)
    // {
    //     for(int j = i;j < s.size();j++)
    //     {
    //         num[i][j] = stoll(s.substr(i,j + 1));
    //         cout << num[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    for(int i = 1;i <= len;i++)
    {
        for(int j = i;j <= len;j++)
        {
            num[i][j] = num[i][j - 1] * 10 + (s[j - 1] - '0');
            //cout << num[i][j] << " ";
        }
        //cout << endl;
    }

    memset(dp,0x3f,sizeof dp);
    dp[0][0] = -1;
    for(int i = 1;i <= len;i++)
    {
        for(int k = 0;k <= n;k++)
        {
            for(int j = i - 1;j >= 0 && n >= num[j + 1][i];j--)
            {
                if(k >= num[j + 1][i])
                {
                    dp[i][k] = min(dp[i][k],dp[j][k - num[j + 1][i]] + 1);
                }
            }
        }
    }

    for(int i = 0;i <= len;i++)
    {
        for(int j = 0;j <= n;j++)
        {
            if(dp[i][j] == INF)
            {
                cout << "INF" << " ";
            }
            else cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    // if(dp[len][n] <= 39)
    // {
    //     cout << dp[len][n] << endl;
    // }
    // else cout << -1 << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}